﻿//  

#region

using System.Collections.Generic;
using Microsoft.Practices.Composite.Logging;

#endregion

namespace pushbomb.composite.core.Infrastructure
{
    public class ObservableLogger : ILoggerFacade
    {
        private readonly Queue<LogEntry> _items = new Queue<LogEntry>();

        public IEnumerable<LogEntry> PendingItems
        {
            get
            {
                while (_items.Count > 0)
                    yield return _items.Dequeue();
            }

        }

        #region ILoggerFacade Members

        public void Log(string message, Category category, Priority priority)
        {
            var entry = new LogEntry {Message = message, Cat = category, pri = priority};
            _items.Enqueue(entry);
            //       var evtAgg = ServiceLocator.Current.GetInstance<IEventAggregator>();
            //       var evt = evtAgg.GetEvent<LogItemEntered>();

            //       if (evt != null)
            //       {
            //           evt.Publish(entry);
            //       }
            //}

            #endregion
        }

     }
}